"""
Input:
64:2,128:1,32:4,1:128
50,36,64,128,127
Output:
true,true,true,false,false
"""
def main():
    memo_dict = {}
    for item in input().split(','):
        memo, num = map(int, item.split(':'))
        memo_dict[memo] = num
    memo_dict = {k: memo_dict[k] for k in sorted(memo_dict)}
        
    req_list = list(map(int, input().split(',')))
    ans = []
    for req in req_list:
        flag = 'false'
        for k in memo_dict.keys():
            if(k >= req and memo_dict[k] > 0):
                memo_dict[k] -= 1
                flag = 'true'
                break
        ans.append(flag)
        
    print(','.join(ans))

if __name__ == "__main__":
    main()